********************************************************************************
*Step 1 of replication
********************************************************************************
********************************************************************************
*Get old_data
********************************************************************************

*the following gets to estimation_temp.dta, saved as "C:\Users\awcassidy1\Dropbox\jmp_new\programs/estimation_temp.dta"
*FOR LATER: split up clean1

*eventually gets to crucial clean file combined_5.
*also makes audit_3
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/clean1a.do"

do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/clean1b.do"

*it has input combined_5 and outputs combined_6
*this file also does a balance table for non-compliers but i think it should also 
*are main results good if i do this?
*do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/clean2.do"
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/clean2_and_table_a10.do"

*prepare fuel savings data for later use.
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/fuel_savings_prep.do"


*THESE NEXT TWO STEPS ARE NOW COMBINED INTO A DIFFERENT ONE- CHECK IT WORKS!

/**gets temp1_1, using input combined_6
*for this, i'm scared of deleting so I'm gonna try commenting out instead.
*this used to be called estimation1_new_a
*i seriously doubt anything in here does anything.
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/make_temp_1_1.do"
*I don't know what this does. It takes in temp1_1 and makes estimation1_temp
*but i'm really not sure what exactly it does. Maybe just add some labels?
*a good test would be to use test_estimation1_c instead and if everything else 
*still works we can eliminate this step.
*do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/estimation1_new_c.do"
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/test_estimation1_c.do"
*/
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/make_estimation_data.do"

*makes table 9 (bigsumtableld.tex)
*also used to be called estiamtion1_new_b and used to make correlation between audit vars.
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/table_9.do"



*if it's not working, put it back to estimation1_new_c.
*FIGURE THIS OUT!
*After you make sure everything else works.
*I don't know why we wouldn't just use temp1_1?


*the file size for estimation_temp is 303,171 KB.

*it was then resaved as old_data.


********************************************************************************
*NOW DO SURVEY STUFF
********************************************************************************
*MUST BE DONE BEFORE CUBES.
*makes the data file survey_sum.dta
*also makes table 1 (sum_survey_all.tex)
*makes a table that is not shown (sum_survey_all_demeaned.tex) just to check that 
*things don't change much when we demean by realtor-specific averages.
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/clean_survey_and_table_1.do"

*this separates main and test data and creates test_data.dta, the test data,
*and data_used_in_main_regs 
* (data from only the main specification- that is, the data with one sale before and 1 sale after)
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/separate_main_and_test_data.do"


*all the dendrograms, cross validation, etc.
*it also makes the file temp.dta
*figures: A2 and A3
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/treelet_1.do"


*then get the loadings from treelet transform and save them to another file so we can use them later.
*also output treelet loadings table .
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/treelet_2_and_table_a1.do"

*then do the following, which exports the cubes and key for the cubes. 
*This one calls setup_cubes, which uses test_data.
*figures A6and A7, with some other robustness checks.
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs\cubes.do"

*this makes the data file with observability indices.
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/make_data_with_obs_indices.do"

*this gets us the figure 1 (cap_by_feature_miss0_stand1_.pdf)
*used to be called cap_by_feature_with_program_fd_try
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/fig_1.do"


*the following gets us:
 *Table 2 main_main.tex
*Table 3 

/*main vars and pretrends gets us the following tables:
main_main (Table 2)
main_plus_3sale ()
*/
*used to be called this: main vars and pretrends.do

*main tables
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/tables_2_to_4.do"

*using above median less binary variable
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/table_5.do"

*next is the propensity score matching stuff
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/tables_6_and_a2_and_fig_a8.do"

*next is capitalization of savings.
*savings_main.tex
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/table_7.do"

*heterogeneous effects by age and square footage
*less_het.tex
*Table 8.
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/table_8.do"
*table 9 is above. it's just summary stats.

*makes tables a3, a4 and a5
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/tables_a3_a4_a5.do"

*makes tables a6 and a7
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/tables_a6_a7.do"

*Note on why it may appear there are tables missing:
* table a8 is not estimation. neither is table a9
*table a10 is above.

*makes table a11
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/table_a11.do"

*this makes table in_sample_vs_otheraudited_std_diffs (table a12), as well as 
*figures Less_kdensity_main_vs_other_audited.pdf, 
*More_Fuel_kdensity_main_vs_other_audited.pdf, 
*and More_Other_kdensity_main_vs_other_audited.pdf, which go into figure 9.
do "C:\Users\awcassidy1\Dropbox\jmp_new\programs/table_a12_fig_a9.do"

